using UnityEngine;
using System.Collections;

public class TelaGUI : MonoBehaviour {
	
public Texture2D imagSentinel;
public Texture2D imagBird;
public Texture2D imagJuggernaut;
public Texture2D imagBomberGuy;
public GameObject sentinel;
public GameObject bird;
public GameObject juggernaut;
public GameObject bomberGuy;
public static GameObject torreAtual;
		
	// Use this for initialization
	void Start () 
	{
		
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(Input.GetKeyDown(KeyCode.Escape))
		{
			Destroy(torreAtual);
		}
	}
	
	void OnGUI() 
	{
		float posY = Screen.height - Screen.height/5;
		float larguraBotoes = Screen.height/5 - ((Screen.height/5)/4);
		int numTorres = 4;
		
		GUI.Box(new Rect(0,posY -5, Screen.width, Screen.height/5),"");
		
		if(GUI.Button(new Rect(Screen.width/numTorres,posY,larguraBotoes,larguraBotoes),imagSentinel)) 
		{
			Destroy(torreAtual);
			torreAtual = (GameObject)Instantiate(sentinel, sentinel.transform.position, Quaternion.identity);
		}

		if(GUI.Button(new Rect(Screen.width/numTorres + (larguraBotoes + 10),posY,larguraBotoes,larguraBotoes),imagBird)) 
		{
			Destroy(torreAtual);
			torreAtual = (GameObject)Instantiate(bird, sentinel.transform.position, Quaternion.identity);
		}
		
		if(GUI.Button(new Rect(Screen.width/numTorres + (larguraBotoes + 10) * 2,posY,larguraBotoes,larguraBotoes),imagJuggernaut)) 
		{
			Destroy(torreAtual);
			torreAtual = (GameObject)Instantiate(juggernaut, sentinel.transform.position, Quaternion.identity);
		}
		
		if(GUI.Button(new Rect(Screen.width/numTorres + (larguraBotoes + 10) * 3,posY,larguraBotoes,larguraBotoes),imagBomberGuy)) 
		{
			Destroy(torreAtual);
			torreAtual = (GameObject)Instantiate(bomberGuy, sentinel.transform.position, Quaternion.identity);
		}
	}
}
